# main.py
from fastapi import FastAPI, Query
from server_data import search_server

app = FastAPI(title="服务器信息查询接口")

@app.get("/query")
def query_server(field: str = Query(..., description="字段名"),
                 value: str = Query(..., description="字段值")):
    """
    查询服务器信息，支持字段如：服务器名称、IP地址、用户、密码、所属部门、操作系统版本、机架编号等
    """
    result = search_server(field, value)
    if not result:
        return {"message": "未找到对应服务器"}
    return {"result": result}

